package com.ty.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.entity.Carts;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author txy
 * @since 2024-01-30
 */
public interface CartsMapper extends BaseMapper<Carts> {
    @Select("select * from carts ${ew.customSqlSegment}")
    @Results({
            //因为type_id字段拿去关联外表，想要赋值给bookinfo还要再映射一次
            @Result(property = "periodicalId", column = "periodical_id"),
            @Result(property = "periodical", column = "periodical_id",
                    one = @One(select = "com.ty.mapper.BookMapper.selectById"))
    })
    Page<Carts> selectCarts(Page<Carts> page, @Param(Constants.WRAPPER) Wrapper<Carts> wrapper);
    @Select("select * from carts ${ew.customSqlSegment}")
    @Results({
            //因为type_id字段拿去关联外表，想要赋值给bookinfo还要再映射一次
            @Result(property = "periodicalId", column = "periodical_id"),
            @Result(property = "periodical", column = "periodical_id",
                    one = @One(select = "com.ty.mapper.BookMapper.selectById"))
    })
    List<Carts> selectCart(@Param(Constants.WRAPPER) Wrapper<Carts> wrapper);
}
